<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var num1=1,num2=2,str="+";
        if(str==="+"){
            console.log(num1+num2);
        }else if(str==="-"){
            console.log(num1-num2);
        }else if(str==="*"){
            console.log(num1*num2);
        }else if(str==="/"){
            console.log(num1/num2);
        }

        switch(str){
            case "+":console.log(num1+num2);break;
            case "-":console.log(num1-num2);break;
            case "*":console.log(num1*num2);break;
            case "/":console.log(num1/num2);break;
        }
    </script>
</body>
</html>